package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.vo.BarChartVo;
import com.ruoyi.system.service.IRecordManageChartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 可视化图表  Controller
 *
 * @author tangrs
 * @date 2023-03-06
 */
@RestController
@RequestMapping("/system/cart")
public class RecordManageChartController {

    @Autowired
    IRecordManageChartService iRecordManageChartService;

    /**
     * 按部门统计：案卷，卷内
     */
    @PreAuthorize("@ss.hasPermi('system:archives:list')")
    @GetMapping("/byDept")
    public AjaxResult chartByDept() {
        Map<String, Object> map = new HashMap<>();
        List<BarChartVo> barList = iRecordManageChartService.selectChartByDept(map);
        return AjaxResult.success(barList);
    }

    /**
     * 按档案期限统计：案卷，卷内
     */
    @PreAuthorize("@ss.hasPermi('system:archives:list')")
    @GetMapping("/byLimit")
    public AjaxResult chartByLimit() {
        Map<String, Object> map = new HashMap<>();
        List<BarChartVo> barList = iRecordManageChartService.selectChartByLimit(map);
        return AjaxResult.success(barList);
    }

    /**
     * 按档案类型统计：案卷，卷内
     */
    @PreAuthorize("@ss.hasPermi('system:archives:list')")
    @GetMapping("/byType")
    public AjaxResult chartByType() {
        Map<String, Object> map = new HashMap<>();
        List<BarChartVo> barList = iRecordManageChartService.selectChartByType(map);
        return AjaxResult.success(barList);
    }

    /**
     * 按档案类型统计：归档案卷+卷内
     */
    @PreAuthorize("@ss.hasPermi('system:archives:list')")
    @GetMapping("/byTypeArch")
    public AjaxResult chartByTypeArch() {
        Map<String, Object> map = new HashMap<>();
        List<BarChartVo> barList = iRecordManageChartService.selectChartByTypeArch(map);
        return AjaxResult.success(barList);
    }

    /**
     * 按档案类型统计：年度利用
     */
    @PreAuthorize("@ss.hasPermi('system:archives:list')")
    @GetMapping("/byTypeSearch")
    public AjaxResult chartByTypeSearch() {
        Map<String, Object> map = new HashMap<>();
        List<BarChartVo> barList = iRecordManageChartService.selectChartByTypeSearch(map);
        return AjaxResult.success(barList);
    }

    /**
     * 按年度统计：年度利用
     */
    @PreAuthorize("@ss.hasPermi('system:archives:list')")
    @GetMapping("/byYearSearch")
    public AjaxResult chartByYearSearch() {
        Map<String, Object> map = new HashMap<>();
        List<BarChartVo> barList = iRecordManageChartService.selectChartByYearSearch(map);
        return AjaxResult.success(barList);
    }
}
